<template>
  <div style="border-radius: 4px;margin: 20px;">
    <div align="center" style="margin: 40px;" class="filter-container filter1">
<!--      <el-select v-model="listQuery.workshop" placeholder="请选择">-->
<!--        <el-option-->
<!--          v-for="item in options"-->
<!--          :key="item.value"-->
<!--          :label="item.label"-->
<!--          :value="item.value">-->
<!--        </el-option>-->
<!--      </el-select>-->
<!--      <el-radio-group v-model="listQuery.workshop">-->
<!--        <el-radio label="chilun">齿轮车间</el-radio>-->
<!--        <el-radio label="hanjie">焊接车间</el-radio>-->
<!--      </el-radio-group>-->
      <el-date-picker
        v-model="listQuery.month"
        type="month"
        style="margin-left: 2%"
        placeholder="选择月"
      />
      <el-button v-waves class="filter-item" style="width: 100px;margin-left: 2%" type="primary" icon="el-icon-search" @click="handleFilter">
        搜索
      </el-button>
    </div>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      height="900"
      style="width: 100%"
    >
      <el-table-column prop="workpieceCode" label="工件编码" width="180">
        <template slot-scope="scope">
          {{ scope.row.workpieceCode }}
        </template>
      </el-table-column>
      <el-table-column prop="cmaterialName" label="物料名称">
        <template slot-scope="scope">
          {{ scope.row.materialName }}
        </template>
      </el-table-column>
      <el-table-column prop="batchCode" label="产品批次号">
        <template slot-scope="scope">
          {{ scope.row.batchCode }}
        </template>
      </el-table-column>
<!--      <el-table-column prop="workshop" label="提交单位">-->
<!--        <template slot-scope="scope" v-if="scope.row.workshop=='chilun'">-->
<!--         齿轮车间-->
<!--        </template>-->
<!--        <template slot-scope="scope" v-else-if="scope.row.workshop=='焊接'">-->
<!--          焊接车间-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column prop="processName" label="不良工序名称">
        <template slot-scope="scope">
          {{ scope.row.processName }}
        </template>
      </el-table-column>
      <el-table-column prop="failedNum" label="不合格数量">
        <template slot-scope="scope">
          {{ scope.row.failedNum }}
        </template>
      </el-table-column>
      <el-table-column prop="planInstructionCode" label="生产指令单编码">
        <template slot-scope="scope">
          {{ scope.row.planInstructionCode }}
        </template>
      </el-table-column>
      <el-table-column prop="qualityStatus" label="质量状态（不合格/报废）">
        <template slot-scope="scope">
          {{ scope.row.qualityStatus }}
        </template>
      </el-table-column>
      <el-table-column prop="qualityFeatureName" label="不良质量特性名称">
        <template slot-scope="scope">
          {{ scope.row.qualityFeatureName }}
        </template>
      </el-table-column>
    </el-table>
<!--    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />-->
  </div>
</template>
<style>
  *{font-size: 12px;}
</style>

<script>
import { fetchList } from '@/api/quality'
import Pagination from '@/components/Pagination'

export default {
  components: { Pagination },
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'gray',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: null,
      listLoading: true,
      total: 0,
      options: [{
        value: 'chilun',
        label: '车轮车间'
      }, {
        value: 'weld',
        label: '焊接车间'
      }],
      listQuery: {
        page: 1,
        limit: 10,
        month: '2019-10',
        workshop: ''
      },
      value: new Date()
    }
  },
  created() {
    this.getList()
    console.log('---' + this.list)
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total

        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    }
  }
}

</script>
